home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 2.2 KB | 119 lines | [TEXT/CWIE] |
- // ArrangementBase.cp
-
- #ifndef ArrangementBase_h
- #include "ArrangementBase.h"
- #endif
- #ifndef ArrangedPane_h
- #include "ArrangedPane.h"
- #endif
- #ifndef MinMax_h
- #include "MinMax.h"
- #endif
- #ifndef ViewMap_h
- #include "ViewMap.h"
- #endif
-
- ArrangementBase::ArrangementBase( ArrangedPane *thePanes,
- uint32 thePaneCount )
- : panes( thePanes ),
- paneCount( thePaneCount )
- {
- Assert( thePanes != 0 );
- }
-
- void ArrangementBase::SetParents()
- {
- for ( uint32 i = 0; i < paneCount; i++ )
- panes[i].parent = this;
- }
-
- void ArrangementBase::Draw( const ViewMap& toDraw ) const
- {
- ViewMap paneMap( toDraw );
-
- for ( uint32 i = 0; i < paneCount; i++ )
- {
- const Pane& pane( panes[i] );
-
- paneMap.Set( toDraw, pane.Bounds() );
- if ( !paneMap.Visible() )
- continue;
-
- pane->Draw( paneMap );
- }
- }
-
- TangibleView *ArrangementBase::Touch( PointObject p )
- {
- for ( uint32 i = 0; i < paneCount; i++ )
- {
- const Pane& pane( panes[i] );
-
- if ( pane.Bounds().Contains( p ) )
- return pane->Touch( p );
- }
-
- return 0;
- }
-
- void ArrangementBase::GainMapping()
- {
- Arrange( Owner().Bounds() );
-
- for ( uint32 i = 0; i < paneCount; i++ )
- panes[i].MapTo( Owner().Window() );
- }
-
- void ArrangementBase::LoseMapping()
- {
- for ( uint32 i = 0; i < paneCount; i++ )
- panes[i].Unmap();
- }
-
- void ArrangementBase::ChangeBounds( Rectangle )
- {
- if ( Mapped() )
- Arrange( Owner().Bounds() );
- }
-
- uint16 ArrangementBase::Minimum( uint16 (Sizeable::*dimension)() ) const
- {
- uint16 min = maxuint16;
-
- for ( uint32 i = 0; i < paneCount; i++ )
- if ( !panes[i].IsEmpty() )
- min = Min( min, ( (*panes[i]).*dimension)() );
-
- return min;
- }
-
- uint16 ArrangementBase::Maximum( uint16 (Sizeable::*dimension)() ) const
- {
- uint16 max = 0;
-
- for ( uint32 i = 0; i < paneCount; i++ )
- if ( !panes[i].IsEmpty() )
- max = Max( max, ((*panes[i]).*dimension)() );
-
- return max;
- }
-
- uint16 ArrangementBase::Total( uint16 (Sizeable::*dimension)() ) const
- {
- uint16 total = 0;
- for ( uint32 i = 0; i < paneCount; i++ )
- {
- if ( panes[i].IsEmpty() )
- continue;
-
- uint16 paneSize = ((*panes[i]).*dimension)();
-
- if ( CanAdd( total, paneSize ) )
- total += paneSize;
- else
- return maxuint16;
- }
-
- return total;
- }
-